package com.frxuexi.myvideo

import com.frxuexi.lib_base.entity.MyVideoBean
import com.frxuexi.lib_base.entity.MyVideoCommentBean
import com.frxuexi.lib_base.http.VideoApiService
import com.frxuexi.lib_base.mvvm.BaseViewModel
import com.frxuexi.lib_base.utils.SignLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import retrofit2.http.Query
import javax.inject.Inject

@HiltViewModel
class MyVideoViewModel @Inject constructor(val apiService: VideoApiService):BaseViewModel(){

    val videoError = SignLiveData<String>()
    val myVideoData=SignLiveData<MyVideoBean>()
    fun getMyVideos(page:Int,size:Int){
        httpRequest({apiService.getMyVideos(page,size)},myVideoData::postValue,videoError::postValue)
    }

    val addLoveData=SignLiveData<String>()
    fun addLove(vid:Int){
        httpRequest({apiService.addLove(vid)},addLoveData::postValue,videoError::postValue)
    }

    val cancelLoveData=SignLiveData<String>()
    fun cancelLove(vid:Int){
        httpRequest({apiService.cancelLove(vid)},cancelLoveData::postValue,videoError::postValue)
    }

    val myCommentsData=SignLiveData<MyVideoCommentBean>()
    fun getMyComments(vid:Int){
        httpRequest({apiService.getMyComments(vid)},myCommentsData::postValue,videoError::postValue)
    }

    val myTwoCommentsData=SignLiveData<MyVideoCommentBean>()
    fun getMyTwoComments(currentPage:Int,pageSize:Int, rootId:Int, videoId:Int){
        httpRequest({apiService.getMyTwoComments(currentPage, pageSize, rootId, videoId)},myTwoCommentsData::postValue,videoError::postValue)
    }

    val  addMyCommentData=SignLiveData<MyVideoCommentBean>()
    fun addMyComment(map: Map<String,Any>){
        httpRequest({apiService.addMyComment(toBody(map))},addMyCommentData::postValue,videoError::postValue)
    }

    val  huiCommentData=SignLiveData<MyVideoCommentBean>()
    fun huiComment(map: Map<String,Any>){
        httpRequest({apiService.huiComment(toBody(map))},huiCommentData::postValue,videoError::postValue)
    }

    val addGuanData=SignLiveData<String>()
    fun addGuan(map: Map<String,String>){
        httpRequest({apiService.addGuan(toBody(map))},addGuanData::postValue,videoError::postValue)
    }

    val cancelGuanData=SignLiveData<String>()
    fun cancelGuan(map: Map<String,String>){
        httpRequest({apiService.cancelGuan(toBody(map))},cancelGuanData::postValue,videoError::postValue)
    }
}